package com.pn.controller;


import com.pn.entity.Client;

import com.pn.service.ClientService;
import com.pn.utils.PageBean;
import com.pn.utils.Result;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("client")
public class ClientController {
    @Autowired
    private ClientService clientService;

    //显示客户信息
    @GetMapping("/client-page-list")
    public Result<PageBean<Client>> clientPageList(Client client){
        PageBean pageBean = clientService.clietPageList(client);
        return Result.ok(pageBean);
    }

    //修改客户
    @PutMapping("/client-update")
    public Result clientUpdate(@RequestBody Client client){
        return clientService.clientUpdate(client);
    }


    //添加客户
    @PostMapping("/client-add")
    public Result clientAdd(@RequestBody Client client){
        return clientService.clientAdd(client);
    }

    //删除客户
    @DeleteMapping("/client-delete/{clientId}")
    public Result clientDelete(@PathVariable Integer clientId){
        return clientService.clientDelete(clientId);
    }
}
